using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;

namespace Data.Database
{
    public class Adapter
    {
        //Clave por defecto a utlizar para la cadena de conexion
        const string consKeyDefaultCnnString = "ConnStringLocal";

        private SqlConnection _sqlConn;
        public SqlConnection sqlConn
        {
            get { return _sqlConn; }
            set { _sqlConn = value; }
        }

        protected SqlConnection CreateConnection() //Aca antes decia public static SqlConnection CreateConnection()
        {
            //SqlConnection sqlConn;
            string connectionString = "";

            try
            {
                //Se obtiene el Conn String desde el archivo de configuracion
                connectionString = Util.Configuracion.GetValue(consKeyDefaultCnnString);
                sqlConn = new SqlConnection();
               
                sqlConn.ConnectionString = Util.Configuracion.GetValue(consKeyDefaultCnnString);
                return sqlConn;
            }
            finally
            {
                sqlConn = null;
            }
        }

        /*
        protected void OpenConnection()
        {
            string Conn = ConfigurationManager.ConnectionStrings[consKeyDefaultCnnString].ConnectionString;
            sqlConn = new SqlConnection(Conn);
            sqlConn.Open();
        }

        protected void CloseConnection()
        {
            sqlConn.Close();
            sqlConn = null;
        }

*/
    }
}
